import { defineStore } from 'pinia';
import { ref } from 'vue'
export const useUserStore = defineStore('user',() => {
	//令牌
	const token = ref('')
	const userInfo = ref({})
	//更新令牌
	const updateToken = (newToken) => {
		this.token = newToken
	}
	//清除令牌
	const clearToken = () => {
		this.token = ''
	}
	//更新用户信息
	const updateUserInfo = (val) => {
		this.userInfo = val
	}
	//清除用户信息
	const clearUserInfo = () => {
		this.userInfo = {}
	}
	return{
		token,
		userInfo,
		updateToken,
		clearToken,
		updateUserInfo,
		clearUserInfo
	}
},{persist:true})
export default useUserStore
